<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr1 = [1,2,3,4,5,1,2,3,2,8,9];
        let set1 = new Set(arr1);
        console.log(set1);
        let arr2 = [...set1]
        // 转成数组
        console.log(arr2);
        // =======================================================

        let str1 = 'hello';
        let set2 = new Set(str1);
        console.log(set2);
        let arr3 = [...set2];
        // 加""是去掉逗号
        console.log(arr3.join(""));

        // =================================
        set1.add(7);//添加一项
        // set1.add[2,1,3,4,5,6]
        set1.delete(5)  //删除一项
        // 返回一个布尔值，表示该值是否为`Set`的成员
        let res = set1.has(3);
        console.log(res);
        set1.clear(); // 清除选项
        console.log(set1);
    </script>
</body>
</html>